<template>
  <div class="action">
        <div class="action-setting" @click="visible = true"><a-icon type="tool" /></div>
        <a-modal :visible="visible" title="设置" @cancel="visible = false" @ok="save">
          <a-form>
            <a-form-item label="kindlegen位置">
              <a-row>
                <a-col :span="16" >
                  <a-input v-model="kindlegen"></a-input>
                </a-col>
                <a-col :span="6" :offset="1">
                  <a-button type="" @click="selectFile">选择文件</a-button>
                </a-col>
              </a-row>
            </a-form-item>
          </a-form>
        </a-modal>
  </div>
</template>

<script>
import { KINDLEGEN } from '@/api/constant'
export default {
  data () {
    return {
      visible: false,
      kindlegen: ''
    }
  },
  created () {
    this.kindlegen = localStorage.getItem(KINDLEGEN)
  },
  methods: {
    selectFile () {
      let file = this.$electron.remote.dialog.showOpenDialogSync()
      if (file && file[0]) {
        this.kindlegen = file[0]
      }
    },
    save () {
      localStorage.setItem(KINDLEGEN, this.kindlegen)
      this.visible = false
    }
  }
}
</script>

<style>

</style>